import {
  defineConfig,
  transformerVariantGroup,
  transformerDirectives,
} from 'unocss'
import { presetWind3 } from '@unocss/preset-wind3'

import presetRemToPx from '@unocss/preset-rem-to-px'

export default defineConfig({
  // 使用预设时presetUno是必须的
  presets: [
    presetWind3(),
    presetRemToPx({ baseFontSize: 4 }) as any,
  ],
  transformers: [
    // lt-sm:(w-100vw c-#111)
    transformerVariantGroup(),
    // @apply
    transformerDirectives(),
  ],
  theme: {
    colors: {
      bBlue: '#00afff',
      bBlueShallow: '#00aeff1a',
      bOrange: '#fc8a1a',
    },
  },
  shortcuts: {
    // bGradient: 'bg-gradient-to-b from-#d1f0ff to-#f5f6f7',
    'M-block': 'bg-#fff rounded-8',
    'M-py': 'py-8 text-(14 #333)',
    'M-py-b': 'py-8 text-(14 #333) b-b-(1 solid #e8e8e8)',
    'M-b-b': 'b-b-(1 solid #e8e8e8)',

  },
  rules: [
    // 多行文本超出部分省略号 line-n。如line-1,line-2 (已内置 line-clamp-n)
    [
      /^line-(\d+)$/,
      ([, l]) => {
        if (~~l === 1) {
          return {
            'overflow': 'hidden',
            'text-overflow': 'ellipsis',
            'white-space': 'nowrap',
            'width': '100%',
          }
        }
        return {
          'overflow': 'hidden',
          'display': '-webkit-box',
          '-webkit-box-orient': 'vertical',
          '-webkit-line-clamp': l,
        }
      },
    ],
    [
      'safe-area-inset-bottom',
      { 'padding-bottom': 'env(safe-area-inset-bottom)' },
    ],
  ],
})
